#include "cabecera.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
/*
char* cambiaMayusculas(char* cadena){
	int i;
	char* aux = malloc(100*sizeof(char));
	for(i=0; i<strlen(cadena); i++){
		if( (*(cadena+i) >= 97) && (*(cadena+i) <= 122)){
			*(aux+i) = *(cadena+i) - 32;
		}
		else
		{
			if(*(cadena+i) == 177){
				*(aux+i) = 145;
			}
			else if(*(cadena+i) == 177){
				// POH ME SALTO EL CARACTER RARO ESE QUE SALE
			}
			else
			{
				*(aux+i) = *(cadena+i);
			}
		}
	}
	return aux;
}
*/


char cambiaMayusculas(char caracter)
{
		if( (caracter >= 97) && (caracter <= 122)){
			return (caracter - 32);
		}
		else
		{
			if(caracter == -79){
				return -111;
			}
			else
			{
				return caracter;
			}
		}
}


int aMayusculas(char* ficheroOrig, char* ficheroDestino){
	FILE *orig, *destino;
	int caracter;
	orig = fopen(ficheroOrig, "r");
	destino = fopen(ficheroDestino, "w");
	if(orig == NULL){
		fclose(destino);
		return 2;
	}
	if(destino == NULL){
		fclose(orig);
		return 3;
	}

	while((caracter = fgetc(orig)) != EOF ){

			fputc(cambiaMayusculas(caracter),destino);

	}
	fclose(destino);
	fclose(orig);
	return 1;
}
